package mongo.db.clients.firsts;

import java.util.concurrent.Callable;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.MongoClient;

public class MongoExecutorService implements Callable<Integer> {
	
	
	MongoClient client = null;
	DB db;
	DBCollection collection;

	public MongoExecutorService(MongoClient client) {
		this.client = client;
		this.db = client.getDB("netflowdb");
		this.collection = db.getCollection("netflow_column_list");
	}

	@Override
	public Integer call() throws Exception {
		DBCursor iter = collection.find(new BasicDBObject("routerip", "172.16.36.11")).sort(new BasicDBObject("timestamp", -1)).limit(1);
		while (iter.hasNext())
			System.out.println(iter.next());
		return 1;
	}
	
	
	

}
